package dao;

import com.xugou.dao.OrderDao;
import com.xugou.pojo.Order;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Date;
import java.util.List;

/**
 * @author xugou
 * @date 2022/5/6  23:43
 */
public class ThinkTestOrder {

    @Test
    public void testOrder1(){
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        OrderDao orderDao = context.getBean("orderDao", OrderDao.class);
        List<Order> allOrder = orderDao.getAllOrder();
        System.out.println("=========================");
        for (Order order : allOrder) {
            System.out.println(order);
        }
    }

    @Test
    public void testOrder2(){
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        OrderDao orderDao = context.getBean("orderDao", OrderDao.class);
        Order orderInf = orderDao.getOrderById(1);
        System.out.println(orderInf);
    }

    @Test
    public void testOrder3(){
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        OrderDao orderDao = context.getBean("orderDao", OrderDao.class);
        int i = orderDao.deleteOrderById(1);
        //1就是成功
        System.out.println(i);
        System.out.println(orderDao.getOrderById(1));
    }



}
